# _*_ encoding:utf-8 _*_
from rest_framework.permissions import IsAdminUser
from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response

from meiduo_admin.serializers.channel_serializers import ChannelModelSerializer, ChannelGroupSerializer
from goods.models import GoodsChannel, GoodsChannelGroup
from meiduo_admin.paginations import MyPage


class ChannelViews(ModelViewSet):
    permission_classes = [IsAdminUser]

    queryset = GoodsChannel.objects.all()
    serializer_class = ChannelModelSerializer
    pagination_class = MyPage

    def get_group(self, request):
        queryset = GoodsChannelGroup.objects.all()
        serializer = ChannelGroupSerializer(queryset, many=True)

        return Response(serializer.data)

